home *** CD-ROM | disk | FTP | other *** search
- Path: newshost.cyberramp.net!news
- From: sinan@cyberramp.net (John Noland)
- Newsgroups: comp.lang.c
- Subject: Re: A question on for loop..
- Date: 12 Mar 1996 01:26:13 GMT
- Organization: Prose Software
- Distribution: world
- Message-ID: <4i2jrl$ect@newshost.cyberramp.net>
- References: <4hn80a$98q@male.EBay.Sun.COM>
- NNTP-Posting-Host: ramp1-12.cyberramp.net
- X-Newsreader: WinVN 0.99.5
-
- In article <4hn80a$98q@male.EBay.Sun.COM>, murali@sooraj.ebay.sun.com says...
-
- >In the following piece of code:
- >
- >for(i=0;i< 20; i++)
- >{
- > if(condition==FALSE)
- > continue;
- >}
- >
- >Let us assume i=10 before it entered the loop.
-
- I don't understand what this means. How does it matter what the value
- of i was *before* it entered the loop? The for loop is the only one I
- see in your example and it initializes i to zero.
-
- >The condition was false. So the continue statement
- >got executed.
- >
- >Will control now go to the third statement in the for loop?
- >i.e. will i be incremented by 1 and again tested for the condition?
-
- In any loop construct, continue is basically the same as having a goto
- to a label located just before the end-brace for that block.
- for (i=0;i < 20;i++) {
- ...
- ...
- goto contin; /* same as continue */
- ...
- ...
- contin: ;
- }
-
- So, it would end up doing what you say above.
-
- This is straight out of K&R1. (Someone stole my K&R2, and I'm pissed!!)
-
- -John
-
-